<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Company Retrieve</title>

<jsp:include page="header.html"></jsp:include>
</head>
<body>
	<h1>Company Retrieve</h1>
	<div class="resultSection" id="result"></div>
	<div class="footer">
		<button name="home" onclick="goHome();">home</button>
	</div>
</body>
<script type="text/javascript">
//window.onload = function()
function load() 
{
	var company = "<%=request.getParameter("company")%>";
	console.log(company);

	$.ajax({
		url : "rest/search/company",
		type : "get",
		beforeSend : function(xhr)
		{
			xhr.setRequestHeader('company', company);
		},
		dataType : "json",
		success : function(data) 
		{
			if (data == null)	console.log("null data");
			else 
			{
				if (data == null)	console.log("null");
				else 
				{
					console.log(data.product.length);

					if (data.product.length > 1) 
					{
						for ( var i = 0; i < data.product.length; ++i) 
						{
							var entry = data.product[i];

							display(entry);
						}
					} else 
					{
						display(data.product);
					}
				}
			}
		}
	});
	}

$(document).ready(load);
</script>
</html>